package com.cino.demos.controller.batch;

import com.cino.demos.entity.comment.Comment;
import com.cino.demos.service.BatchService;
import com.cino.demos.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class BatchController {

    @Autowired
    private BatchService batchService;

    /**
     * 接收时是数组接收
     * @param ids
     * @return
     */
    @DeleteMapping("/delBatchByArray")
    public Result delBatchByArray(@RequestBody Integer[] ids){
        batchService.delBatchByArray(ids);
        return Result.success();
    }

    @DeleteMapping("/delBatchByList")
    public Result delBatchByList(@RequestBody List<Integer> ids){
        batchService.delBatchByList(ids);
        return Result.success();
    }


    @DeleteMapping("/del")
    public Result del(@RequestBody Comment comment){
        Integer id = comment.getId();
        ArrayList<Integer> array = new ArrayList<>();
        array.add(id);
        batchService.delBatchByList(array);
        return Result.success();
    }

}
